package cn.caplike.demo.google.protobuf.quickstart;

import cn.caplike.demo.google.protobuf.DataInfo;
import com.google.protobuf.InvalidProtocolBufferException;

/**
 * Description:
 *
 * @author LiKe
 * @version 1.0.0
 * @date 2021-12-01 12:47
 */
public class ProtoBufTest {

    public static void main(String[] args) throws InvalidProtocolBufferException {
        final DataInfo.Student student =
            DataInfo.Student.newBuilder().setName("啊哦").setAge(20).setAddress("成都").build();

        byte[] student2ByteArray = student.toByteArray();

        DataInfo.Student student2 = DataInfo.Student.parseFrom(student2ByteArray); // deserialization
        System.out.println(student2);
        System.out.println(student2.getName());
    }
}
